window.onload = function () {
    var regtel = /^1[3|4|5|7|8]\d{9}$/;  // 手机号码正则
    var regyzm = /^\d{6}$/;  //短信验证码正则
    var regpwd = /^[a-zA-Z0-9-_]{6,16}$/; //密码正则
    var tel = document.querySelector('#tel')
    var yzm = document.querySelector('#yzm')
    var pwd = document.querySelector('#pwd')
    var surepwd = document.querySelector('#surepwd')
    //手机号检测
    regexp(tel, regtel);
    //验证码检测
    regexp(yzm, regyzm)
    //密码检测
    regexp(pwd, regpwd);





    function regexp(ele, reg) {
        ele.onblur = function () {
            if (reg.test(this.value)) {
                this.nextElementSibling.className = 'success';
                this.nextElementSibling.innerHTML = '<i class="success_icon"></i> 恭喜您输入正确';
            }
            else {
                this.nextElementSibling.className = 'error';
                this.nextElementSibling.innerHTML = '<i class="erroe_icon"></i> 格式不正确，请重新输入';

            }
        }
    };
    surepwd.onblur = function () {
        if (this.value == pwd.value) {
            this.nextElementSibling.className = 'success';
            this.nextElementSibling.innerHTML = '<i class="success_icon"></i> 恭喜您输入正确';
        } else {
            this.nextElementSibling.className = 'error';
            this.nextElementSibling.innerHTML = '<i class="erroe_icon"></i> 两次密码输入不一致';
        }
    }


}

